package com.xykj.web.controller;

import com.xykj.common.exception.BusinessException;
import com.xykj.common.response.Response;
import com.xykj.pojo.dto.NewStockCalendarDto;
import com.xykj.service.NewStockCalendarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * @ClassDescription: 新股上市日历controller类
 * @author:yzh
 * @create:2025/5/12 20:49
 **/
@RestController
@RequestMapping("/new-stock-calendar")
public class NewStockCalendarController {
    @Autowired
    private NewStockCalendarService newStockCalendarService;

    @GetMapping("/getNewStockCalendar")
    public Response getNewStockCalendar(@RequestParam Integer pageNum, @RequestParam Integer  pageSize){
        if(pageSize==null||pageNum==null){
            throw new BusinessException("页面大小和页号不能为空");
        }
        List<NewStockCalendarDto> newStockCalendarDtoList = newStockCalendarService.queryNewStockCalendar(pageNum, pageSize);
        Integer count = newStockCalendarService.totalNewStockCalendar();
        HashMap<String, Object> map = new HashMap<>();
        map.put("results",newStockCalendarDtoList);
        map.put("total",count);
        return Response.success("查询成功",map);
    }
}
